#ifndef timestamp_h__
#define timestamp_h__


#include    "pch_files.h"
#include <boost/operators.hpp>
#include <string>

namespace muradin{
namespace common
{
	class timestamp:public boost::less_than_comparable<timestamp>
	{
	public:
		timestamp();
		explicit	timestamp(x_int64 millisecond);

		/// got "1234567890.001"
		std::string		to_string()const;
		/// got "yyyy-mm-dd hh:mi:ss.ms"
		std::string		to_formated_string()const;

		x_int64			millisecond()const;

		void			swap(timestamp& tt);

		static	x_int32		ms_of_second();

		/// now time (UTC+0)
		static	timestamp	now();
	private:
		static const x_int32			milliseconds_one_second_=1000;
		x_int64		millisecond_;	//millisecond form EPCOH(1970-1-1 00:00:00)
	};

	static	bool	operator<(const timestamp& lh,const timestamp& rh)
	{
		return lh.millisecond () < rh.millisecond ();
	}
	static	bool	operator==(const timestamp& lh,const timestamp& rh)
	{
		return lh.millisecond () == rh.millisecond ();
	}
	static	x_int64	time_diff_seconds(const timestamp& big_one,const timestamp& small_one)
	{
		x_int64	diff=big_one.millisecond () - small_one.millisecond ();
		return	(diff/timestamp::ms_of_second());
	}
	static	x_int64	time_diff_milliseconds(const timestamp& big_one,const timestamp& small_one)
	{
		return	big_one.millisecond () - small_one.millisecond ();
	}

};//namespace common
};//namespace muradin


#endif // timestamp_h__

/*

 namespace muradin{
 namespace common
 {
 };//namespace common
 };//namespace muradin

*/
